Release 10.1A: OpenEdge Development:
Progress 4GL Handbook


Using BUFFER-COPY to assign multiple fields

The BUFFER-COPY statement, as the name implies, copies like-named fields from one record buffer to another. You can extend the statement to either include or exclude fields from the copy, and to do other assignments of fields with different names and assignments involving expressions. Here is the syntax of the BUFFER-COPY statement:

BUFFER-COPY source-buffer [ { EXCEPT | USING } field . . .] 
   TO target-buffer [ ASSIGN assign-expression … ] [ NO-ERROR ]. 

By default, the BUFFER-COPY statement copies all like-named fields from the source-buffer to the target-buffer. As with any other assignment, if the data types and extents of the fields are not compatible, an error results. Any fields in the source-buffer that don’t have a like-named field in the target-buffer are not copied. Likewise, any fields in the target-buffer that don’t have a like-named field in the source-buffer are ignored. No error results from this mismatch of fields.

If you want to copy only certain fields from the source-buffer, you can do this in one of two ways:

Thus, you can use either option depending on which one lets you specify a shorter list of fields for special handling. You might also want to consider future code maintenance in making this choice. If you use the EXCEPT option, then any fields that you might add in the future to the tables you’re copying will automatically be picked up when you recompile the procedure. If you use the USING option they will not be. The option you choose depends on your reasons for including or excluding fields and on what you want to have happen if the buffer definitions change.

In addition to like-named fields, you can do any other kind of assignment from the source-buffer to the target-buffer using an ASSIGN statement. As with the ASSIGN statements you’ve seen in examples so far, this is basically a list of assignments with the target field on the left side of an equal sign and the source field on the right. You can also include a WHEN phrase in an assignment to define a logical expression that determines whether the assignment is done. For more information, see the section for the ASSIGN statement in the online help or in OpenEdge Development: Progress 4GL Reference .

As with other statements, the NO-ERROR keyword suppresses any error messages that might result from improper assignment and lets you query the ERROR-STATUS handle afterwards instead.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095